package com.schoolCommunity.controller;


import com.schoolCommunity.entity.Information;
import com.schoolCommunity.entity.MailboxAdmin;
import com.schoolCommunity.service.MailboxAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author YTH
 * @since 2020-10-14
 */
@CrossOrigin
@RestController
public class MailboxAdminController {

    @Autowired
    private MailboxAdminService mailboxAdminService;

    //用户给管理员发送邮箱
    @PostMapping("/SendToAdmin")
    public Information SendToAdmin(@RequestBody MailboxAdmin mailboxAdmin) {
        return mailboxAdminService.SendToAdmin(mailboxAdmin);
    }

    //用户获取自己发送的邮箱
    @GetMapping("/GetSendFromMember/{memberId}")
    public Information GetSendFromMember(@PathVariable("memberId") long memberId) {
        return mailboxAdminService.GetSendFromMember(memberId);
    }

    //管理员获取还没有查看的邮箱
    @GetMapping("/GetNoReadMailToAdmin/{adminId}")
    public Information GetNoReadMailToAdmin(@PathVariable("adminId") long adminId) {
        return mailboxAdminService.GetNoReadMailToAdmin(adminId);
    }

    //管理员获取所有收到的邮箱
    @GetMapping("/GetAllMail/{adminId}")
    public Information GetAllMail(@PathVariable("adminId") long adminId) {
        return mailboxAdminService.GetAllMail(adminId);
    }

    //管理员确认阅读了邮箱
    @GetMapping("/queRenGetMail/{MailId}")
    public Information queRenGetMail(@PathVariable("MailId") long MailId){
        return mailboxAdminService.queRenGetMail(MailId);
    }


}

